Working with AR Foundation

AR Foundation Versions Supported by EasyAR

EasyAR Sense Unity Plugin support AR Foundation 4.0.8 or later.

ARFoundation support is implemented as EasyAR Sense custom camera. Personal edition users can use EasyAR for 100 seconds per run when custom camera is chosen in runtime. There is no limitation when using a paid license for EasyAR Sense.

Import AR Foundation Package

If you are using samples from EasyAR, do not open sample Scene before AR Foundation Package imported, or some irregular situations may happen. Suggest to delete and reimport sample if you opened and saved the sample scene before package import.

Skip this step if you already have a usable AR Foundation project.

Import AR Foundation Unity Package using Unity Package Manager,

../_images/image_g7_1.png

To use AR Foundation on Android or iOS, usually you need to import either ARCore XR Plugin or ARKit XR Plugin Unity package into the project. Follow AR Foundation Introduction to setup necessary packages.

Create a Scene Usable that can run AR Foundation

Skip this step if you already have a usable Foundation project.

Follow AR Foundation Introduction to create a usable scene that can run AR Foundation.

A typical AR Foundation scene contains an AR Session and an AR Session Origin.

../_images/image_g7_2.png

It is suggested to make sure the scene could be used normally before adding EasyAR components into the scene.

Add EasyAR Components in the Scene

NOTE: AR Foundation usually sets its clipping planes to (0.1, 20) , this may clip objects away displayed more than 20 meters from the Camera (the device in real world). Please make sure to change its value for your needs before you use them.

Add EasyAR AR Session and other necessary nodes in the scene. You can reference Start from Zero for startups. AR Session can be created from some AR Session presets or constructed from standalone feature nodes using EasyAR Sense > GameObject menu. You need to make sure there is a ARFoundationFrameSource in the session.

AR Session presets from SpatialMap, Cloud SpatialMap, Motion Tracking contain ARFoundationFrameSource

../_images/image_g7_3.png

AR Session presets with the name Motion Fusion from Image Tracking and Object Tracking also contain ARFoundationFrameSource

../_images/image_g7_4.png

To use EasyAR with AR Foundation, ARFoundationFrameSource must be selected as frame source in the AR Session after Session start.

This could usually be done by set ARComponentPicker.FrameSource to FirstAvailableActiveChild and make sure ARFoundationFrameSource is the first frame source that can be used in transform order,

../_images/image_g7_5.png

The NrealFrameSource in above image will not be chosen if Nreal SDK is not imported and added into the scene, so it is safe in this kind of usage.

Or set ARComponentPicker.FrameSource to Specify and specify the frame source to ARFoundationFrameSource .

../_images/image_g7_6.png

ARFoundationFrameSource can be added to AR Session from menu EasyAR Sense > Motion Tracking > Frame Source : AR Foundation if it does not exist in the session.

../_images/image_g7_7.png

Then add targets or maps in the scene, for example, if you want to build Sparse SpatialMap, you need to create SparseSpatialMapController by EasyAR Sense > SpatialMap > Map : Sparse SpatialMap

../_images/image_g1_18.png

Finally, a simple scene for sparse and dense spatial map building with AR Foundation could look like this,

../_images/image_g7_8.png

Scenes can be different according to features in use from both AR Foundation and EasyAR Sense Unity Plugin.

Choose AR Foundation in Runtime

MotionTracking_Fusion sample shows an advanced usage, to choose frame source at app start up according to device capability and enables runtime switch of available frame sources. To achieve this kind of usage, you need to deactive AR Foundation GameObjects and set all required values of all frame sources for availability check, and active AR Foundation GameObjects when this frame source is chosen.

../_images/image_g7_9.png

There are more details in ARFoundationFrameSource.